package com.example.im.bean

import android.annotation.SuppressLint
import android.graphics.Rect
import android.os.Parcel
import android.os.Parcelable

import com.previewlibrary.enitity.IThumbViewInfo

@SuppressLint("ParcelCreator")
data class ThumbView internal constructor(private var photoUrl: String?) : IThumbViewInfo {
    private var bounds: Rect? = null
    private var videoUrl: String? = null

    fun setPhotoUrl(photoUrl: String) {
        this.photoUrl = photoUrl
    }

    fun setBounds(bounds: Rect) {
        this.bounds = bounds
    }

    fun setVideoUrl(videoUrl: String) {
        this.videoUrl = videoUrl
    }

    override fun getUrl(): String? {
        return photoUrl
    }

    override fun getBounds(): Rect? {
        return bounds
    }

    override fun getVideoUrl(): String? {
        return videoUrl
    }

    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(dest: Parcel, flags: Int) {
        dest.writeString(photoUrl)
        dest.writeParcelable(bounds, flags)
        dest.writeString(videoUrl)
    }

    companion object CREATOR : Parcelable.Creator<ThumbView> {
        override fun createFromParcel(source: Parcel): ThumbView {
            return ThumbView(source.readString())
        }

        override fun newArray(size: Int): Array<ThumbView?> {
            return arrayOfNulls(size)
        }
    }

}
